<template>
  <div class="userRoles">
    <dv-border-box-8 style="padding-top: 15px">
      <dv-decoration-7 style="width: 100%; height: 30px"
        >用户角色统计</dv-decoration-7
      >
      <div id="userRoles" style="height: 350px; width: 100%"></div>
    </dv-border-box-8>
  </div>
</template>

<script>
import { getUserRoles } from "@/api/visualization.js";

export default {
  name: "UserRoles",
  data() {
    return {
      userdata: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      getUserRoles().then((res) => {
        console.log(res.data);
        this.userdata = res.data;
        this.initEchart();
      });
    },
    initEchart() {
      let myChart1 = this.$echarts.init(document.getElementById("userRoles"));
      let option1 = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          // orient: "vertical",
          left: "left",
          // 字体颜色
          textStyle: {
            color: "#ffffff",
          },
        },
        series: [
          {
            name: "角色：",
            type: "pie",
            radius: "50%",
             data: [
          { value: this.userdata.artist_count, name: "艺术家" },
          { value: this.userdata.buyer_count, name: "普通用户" },
        ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      option1 && myChart1.setOption(option1);
    },
  },
};
</script>

<style lang="less" scoped></style>
